<p> Implement Causal (masked) Self-Attention for a given set of matrices. 
  Given the query matrix <code>Q</code> of size <code>M×d</code>, key matrix <code>K</code> of size <code>M×d</code>, and value matrix
  <code>V</code> of size <code>M×d</code>, your program should compute the output matrix using the formula:
  $$\text{Attention}_{\text{causal}}(Q, K, V) = \text{softmax}\Bigl(\text{masked}\Bigl( \frac{QK^T}{\sqrt{d}} \Bigr)\Bigr)V$$  
</p>


<p>
  where <code>mask</code> is a causal mask that sets all positions corresponding to keys <strong>after</strong> the current query to \(-\infty\).
  $$$$
  i.e., for query <code>i</code> and key <code>j</code>:
  $$
  \text{masked}(a_{ij}) =
  \begin{cases}
  a_{ij}, & j \le i \\
  -\infty, & j > i
  \end{cases}
  $$
  The softmax function is applied row-wise. <code>Q</code>, <code>K</code>, <code>V</code>, and <code>output</code> are all of data type <code>float32</code>; 
  <code>M</code>, and <code>d</code> are of data type <code>int32</code>.
</p>


<h2>Implementation Requirements</h2>
<ul>
  <li>Use only native features (external libraries are not permitted)</li>
  <li>The
    <code>solve</code> function signature must remain unchanged
  </li>
  <li>The final result must be stored in the output matrix
    <code>output</code>
  </li>
</ul>
<h2>Example 1:</h2>
<p>
<strong>Input:</strong><br>
<code>Q</code> (2×4):
\[
\begin{bmatrix}
1.0 & 0.0 & 0.0 & 0.0 \\
0.0 & 1.0 & 0.0 & 0.0
\end{bmatrix}
\]
<code>K</code> (2×4):
\[
\begin{bmatrix}
1.0 & 0.0 & 0.0 & 0.0 \\
0.0 & 1.0 & 0.0 & 0.0
\end{bmatrix}
\]
<code>V</code> (2×4):
\[
\begin{bmatrix}
1.0 & 2.0 & 3.0 & 4.0 \\
5.0 & 6.0 & 7.0 & 8.0
\end{bmatrix}
\]
</p>

<p>
<strong>Output:</strong><br>
<code>output</code> (2×4):
\[
\begin{bmatrix}
1.0 & 2.0 & 3.0 & 4.0 \\
3.4898374 & 4.4898374 & 5.4898374 & 6.4898374
\end{bmatrix}
\]
</p>


<h2>Example 2:</h2>
<p>
<strong>Input:</strong><br>
<code>Q</code> (2×2):
\[
\begin{bmatrix}
0.0 & 0.0 \\
1.0 & 1.0
\end{bmatrix}
\]
<code>K</code> (2×2):
\[
\begin{bmatrix}
1.0 & 0.0 \\
0.0 & 1.0
\end{bmatrix}
\]
<code>V</code> (2×2):
\[
\begin{bmatrix}
3.0 & 4.0 \\
5.0 & 6.0
\end{bmatrix}
\]
</p>

<p>
<strong>Output:</strong><br>
<code>output</code> (2×2):
\[
\begin{bmatrix}
3.0 & 4.0 \\
5.0 & 6.0
\end{bmatrix}
\]
</p>


<h2>Constraints</h2>
<ul>
  <li>Matrix <code>Q</code>, <code>K</code>, and <code>V</code> are all of size <code>M×d</code></li>
  <li>1 &le; <code>M</code> &le; 10000</li>
  <li>1 &le; <code>d</code> &le; 128</li>
  <li>All elements in <code>Q</code>, <code>K</code>, and <code>V</code> are sampled from<code>[-100.0, 100.0]</code></li>
  <li>Data type for all matrices is <code>float32</code></li>
</ul>